<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('承办部门')"/>
    <link th:href="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.css}" rel="stylesheet">
</head>
<style>
    label {
        font-weight: bold;
    }

    @font-face {
        font-family: 'huawen';
        src: url("/fonts/huawen.ttf");
    }

    .tltieBoder {
        height: 40px;
    }

    .smsnote {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        margin: 2px 0px 0px 15px;
    }

    .add-workNo {
        color: #fff;
        background-color: #3e94c3;
        border-color: #12a1d5;
    }

    .add-wfTag {
        color: #fff;
        background-color: #3e94c3;
        border-color: #12a1d5;
    }

    .commonTag {
        margin: 5px;
        cursor: pointer;
    }

</style>

<body style="background-color: #F4F6FA; font-size: 13px;font-family:'huawen' ;font-weight: bold">
<div class="main-content" style="margin: 0;padding: 0">

    <form id="form-user-add" th:object="${mmailWorkForm}" class="form-horizontal" style="background-color: #F4F6FA">
        <input type="hidden" value="-1" name="callId">
        <input type="hidden" value="-1" name="tapeId">
        <input type="hidden" value="10" name="sendState">
        <input type="hidden" name="fmContent" th:value="${mmailWorkForm.fmContent}">
        <input type="hidden" name="dcntAName" th:value="${mmailWorkForm.dcntAName}">
        <input type="hidden" id="originFK" name="originFK" th:value="${mmailWorkForm.originFK}">
        <input type="hidden" name="pid" th:value="${param.sbId}">
        <div class="col-sm-12">
            <div class="col-sm-12 entering-page">
                <!--    承办部门    -->
                <div class="col-sm-12 tltieBoder">
                    <div class="blueBorder"></div>
                    <h4 style="margin:0 0 0 10px">拟派承办部门</h4>
                    <div class="col-sm-6 smsnote" style="width: auto">
                        <h4>开启短信通知&nbsp;&nbsp;&nbsp;&nbsp;</h4>
                        <input type="checkbox" name="smsInform">
                        <h4 id="paidan" style="display: none">&nbsp;&nbsp;&nbsp;智能匹配部门&nbsp;&nbsp;&nbsp;</h4>
                        <span>
              &nbsp;<input type="text" name="workNo" th:value="${mmailWorkForm.WorkFormNo}"/><button
                                class="btn btn-sm add-workNo" onclick="lookWorkNo()">&nbsp;&nbsp;查询工单详情</button>
            </span>
                    </div>
                    <div style="margin-left: 20px;">
                        <button type="button" class="btn btn-sm add-wfTag" onclick="makeTag()">打标签
                        </button>
                    </div>
                </div>
                <!--该工单标签-->
                <div class="col-sm-12">
                    <div class="form-group col-sm-12">
                        <label class="col-sm-1 control-label entering-pd">该工单标签</label>
                        <div class="col-sm-10 card card-body">
                            <th:block th:if="${wfTag} != null" th:each="item : ${wfTag}">
                                <span class="badge badge-pill badge-light commonTag" th:title="${item['tagName']}"
                                      th:value="${item['tagNo']}">[[${item['tagName']}]]</span>
                            </th:block>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group col-sm-12">
                        <label class="control-label formTitle">工单备注</label>
                        <div style="padding-left: 104px;">
                            <textarea class="form-control" rows="2"
                                      th:text="*{wfRemark}"></textarea>
                        </div>
                    </div>
                </div>
                <!-- 工单编号,工单性质..-->
                <div class="col-sm-12 work-top">
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">工单编号</label>
                        <div class="col-sm-8">
                            <input type="text" name="workFormNo" th:field="*{workFormNo}" disabled value="123"
                                   class="form-control" id="workNumber"
                                   placeholder="请输入名称">
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">工单性质</label>
                        <div class="col-sm-8">
                            <select name="setProId" id="workCharacter" class="form-control">
                                <option value="">-请选择-</option>
                                <option value="11" selected>普通工单</option>
                                <option value="31">呈批工单</option>
                            </select>
                            <input type="hidden" name="setProName">
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">工单主题</label>
                        <div class="col-sm-8">
                            <input type="text" name="fromTopic" th:field="*{fromTopic}" class="form-control"
                                   id="workSubject"
                                   placeholder="请输入名称">
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle is-required">承办单位</label>
                        <div class="col-sm-8">
                            <input type="text" name="sbdeptName" class="form-control" id="deptShort" placeholder=""
                                   autocomplete="off"
                                   onclick="SelectDept()" required="required" th:placeholder="请选择承办部门">
                            <input type="hidden" name="sbdeptId" id="noUnit">
                            <input type="hidden" name="zpFlag" id="zpFlag" value="0">
                            <div class="input-group-append " style="position: absolute;top: 10px;right: 20px;">
                                <span class="glyphicon glyphicon-list-alt" style="color: #206ef7"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle is-required">办理期限</label>
                        <div class="col-sm-8">
                            <input type="text" name="backLimit"
                                   th:value="${@commonServiceImpl.getDeptBackLimit('__${deptId}__',5)}"
                                   class="form-control transaction" id="transaction"
                                   placeholder="请输入名称" required="required">
                            <div class="input-group-append " style="position: absolute;top: 10px;right: 20px;">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle is-required">交办次序</label>
                        <div class="col-sm-8">
                            <select name="seqCode" id="workOrder" class="form-control" required="required">
                                <option value="">-请选择-</option>
                                <option value="10" selected>初次交办</option>
                                <option value="20">再次交办</option>
                                <option value="30">三次交办</option>
                            </select>
                            <input type="hidden" value="初次交办" name="seqName">
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle is-required">办理性质</label>
                        <div class="col-sm-8">
                            <select name="sortCode" class="form-control" required="required">
                                <option value="">-请选择-</option>
                                <option value="11" selected>主办</option>
                            </select>
                            <input type="hidden" name="sortName" value="主办">
                        </div>
                    </div>
                    <div class="form-group col-sm-4 hidden">
                        <label class="control-label formTitle">办理方式</label>
                        <div class="col-sm-8">
                            <select name="dealCode" id="transactionWay" class="form-control" required="required">
                                <option value="">-请选择-</option>
                                <option value="11" selected>研究办理</option>
                                <option value="21">酌情办理</option>
                            </select>
                            <input type="hidden" name="dealName" value="研究办理">
                        </div>
                    </div>

                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">详细地址</label>
                        <div class="col-sm-8">
                            <span class="tworkformprocess-span">[[*{fmAddress}]]</span>
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">派单时间</label>
                        <div class="col-sm-8">
                            <input type="text" name="sendTime" th:value="${sendTime}" disabled
                                   class="form-control workTime" id="workTime" placeholder="请输入名称">
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group col-sm-4">
                        <label class="formTitle control-label is-required entering-pd"
                               style="color: firebrick;">允许延期</label>
                        <div class="col-sm-8" style="color: firebrick;">
                            <label class="check-box">
                                <input name="isDelay" value="0" type="radio" checked>允许
                            </label>
                            <label class="check-box">
                                <input name="isDelay" value="1" type="radio">不允许
                            </label>
                        </div>
                    </div>
                    <div class="form-group col-sm-4" style="margin: 0px 0px 0px 30px;">
                        <label class="formTitle control-label is-required entering-pd"
                               style="color: #184ce9;">允许退回</label>
                        <div class="col-sm-8" style="color: #184ce9;">
                            <label class="check-box">
                                <input name="isGoBack" value="0" type="radio" checked>允许
                            </label>
                            <label class="check-box">
                                <input name="isGoBack" value="1" type="radio">不允许
                            </label>
                        </div>
                    </div>
                </div>
                <!-- 抄送 -->
                <div class="col-sm-12 work-top">
                    <div class="form-group col-sm-4">
                        <label class="formTitle col-sm-4 control-label entering-pd">抄送至</label>
                        <div class="col-sm-8">
                            <input type="text" name="copyToDeptName" class="form-control" id="copyToDeptName"
                                   placeholder=""
                                   autocomplete="off" th:placeholder="请选择抄送部门"
                                   onclick="selectCopyDeptAll()">
                            <input type="hidden" name="copyToDeptId" id="copyToDeptId" value="0">
                        </div>
                    </div>
                </div>
                <!--工单备注-->
                <div class="col-sm-12">
                    <div class="form-group col-sm-12">
                        <label class="control-label formTitle">办理要求</label>
                        <div style="padding-left:104px;">
                            <textarea id="sendDesc" name="sendDesc" maxlength="1000" class="form-control workRemark"
                                      rows="3"
                            >请 XXX 调查处理后直接与来话人联系，并将处理结果抄复我办。请注意来话人个人信息保密。</textarea>
                            <span>还可以输入<i class="workRemarkI">1000</i>个文字</span>
                        </div>
                    </div>
                </div>
                <!--办理期限,备注..-->
                <div class="col-sm-12 work-top">
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">派单备注</label>
                        <div class="col-sm-8">
                            <input name="sendRemark" type="text" class="form-control" id="remark"
                                   placeholder="请输入名称">
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">派发单位</label>
                        <div class="col-sm-8">
                            <input name="sdeptName" th:value="${sdeptName}" type="text" class="form-control"
                                   id="sdeptName"
                                   placeholder="请输入名称">
                            <input type="hidden" name="sdeptId" id="sdeptId" th:value="${sdeptId}">
                        </div>
                    </div>
                    <div class="form-group col-sm-4">
                        <label class="control-label formTitle">派发人</label>
                        <div class="col-sm-8">
                            <input name="suserName" th:value="${suserName}" type="text" class="form-control"
                                   id="distributePerson"
                                   placeholder="请输入名称">
                            <input type="hidden" name="suserNo" th:value="${suserNo}">
                        </div>
                    </div>
                    <input name="deptId" id="deptId" th:value="${deptId}" type="hidden">
                    <input name="fpDirect" id="fpDirect" type="hidden">
                </div>
            </div>

            <div class="col-sm-12 entering-page">
                <!--    工单基本信息    -->
                <div class="col-sm-12 tltieBoder">
                    <div class="blueBorder"></div>
                    <h4 style="margin:0 0 0 10px">工单基本信息</h4>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="control-label formTitle">主题：</label>
                        <div class="col-sm-10">
                            <span class="tworkformprocess-span">[[*{fromTopic}]]</span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="control-label formTitle">内容：</label>
                        <div class="pdl100">
                            <textarea id="fmContent" th:text="*{fmContent}" class="form-control phoneRemark" readonly
                                      style="height: 120px"></textarea>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label  entering-pd">工单号：</label>
                        <div class="col-sm-2">
                            <span class="tworkformprocess-span">[[*{workFormNo}]]</span>
                        </div>
                        <label class="col-sm-2 control-label  entering-pd">流水号：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{wsKey}]]</span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label  entering-pd">类别：</label>
                        <div class="col-sm-2">
                            <span class="tworkformprocess-span">[[*{setProName}]]</span>
                        </div>
                        <label class="col-sm-2 control-label entering-pd spOrange">拟办时限：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{#dates.format(wfLimit,'yyyy-MM-dd HH:mm:ss')}]]</span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd">公开标记：</label>
                        <div class="col-sm-2">
                            <span class="tworkformprocess-span"><span
                                    th:classappend="*{openX == 1 ? 'spLBlue' : 'spLRed'}">[[*{openX == 1 ? '是' : '否'}]]</span><span
                                    th:text="*{openX == 1 ? '' : '(效能办)'}"></span></span>
                        </div>
                        <label class="col-sm-2 control-label entering-pd">摘报：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span"><span
                                    th:classappend="*{reportFlag == 1 ? 'spLBlue' : 'spLRed'}">[[*{reportFlag == 1 ? '是' : '否'}]]</span></span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12 mb10">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd spOrange">创建人：</label>
                        <div class="col-sm-2">
                            <span class="tworkformprocess-span">[[*{iptWorker}]]</span>
                        </div>
                        <label class="col-sm-2 control-label entering-pd">创建时间：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{#dates.format(iptTime,'yyyy-MM-dd HH:mm:ss')}]]</span>
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" id="pbackLimit" th:value="${#dates.format(pbackLimit,'yyyy-MM-dd HH:mm:ss')}"/>
        </div>
    </form>
</div>
<input type="hidden" id="sendRemark" th:value="${sendBack?.sendRemark}">
<div class="modal fade" id="myModal" data-show="true" data-backdrop="static">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">派单备注</h4>
            </div>
            <div class="modal-body" th:text="${sendBack?.sendRemark}"></div>
            <div class="modal-footer">
                <div class="btn-group" role="group" style="padding-right: 140px;">
                    <button type="button" class="btn btn-sm" data-dismiss="modal" style="color: orange;display: none"
                            onclick="getContent()">一键导入备注
                    </button>
                </div>
                <button type="button" class="btn btn-sm" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/ajax/libs/layui/laydate.js}"></script>
<th:block th:include="include :: footer"/>
<script th:src="@{/js/deptdiag.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.js}"></script>
<script>
    var prefix = ctx + "system/mMailWF";
    var sendRemark = $('#sendRemark').val();
    if (sendRemark.length > 0) {
        $("#myModal").modal("show");
    }
    var wfId = [[${wfId}]];
    var mailPk = [[${mailPk}]];
    var workFormNo = $("#workNumber").val();
    var sbId = [[${sbId == null ? 0 : sbId}]];
    var layerIndex = [[${param.layerIndex == null ? 0 :param.layerIndex}]];
    var deptNo = [[${session.ssnObjUser.deptId}]];
    var pbackLimit = document.getElementById('pbackLimit').value;
    var lock = false;
    //不是锦江区
    // if(deptNo != '304040' && pbackLimit != '') {
    //   document.forms[0].backLimit.value = pbackLimit;
    // }

    function submitHandler(index, iframeName, diagId) {
        if (!$('#sdeptId').val().indexOf($('#deptId').val())) {
            $('#fpDirect').val(1);
        } else {
            $('#fpDirect').val(0)
        }
        if ($.validate.form()) {
            var data = $('#form-user-add').serializeArray();
            data.push({name: "wfId", value: wfId});
            data.push({name: "mailPk", value: mailPk});
            data.push({name: "workFormNo", value: workFormNo})
            data.push({name: "pid", value: sbId})
            if (lock) return;
            lock = true;
            var config = {
                url: prefix + '/rManage/sendDeptJson',
                type: "post",
                dataType: "json",
                data: data,
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍候...");
                    // $.modal.disablePopBtn();
                    beforeSend();
                },
                success: function (result) {
                    updateState();
                    if ($('#copyToDeptId').val() != 0) {
                        copyToDept();
                    }
                    $.modal.msgSuccess(result.msg);
                    $.modal.close(index);
                    if (diagId > 0) $.operate.ajaxDiagSuccess(result, 'data-id', $(top.window.document));
                    if (iframeName) {
                        refreshDealList(iframeName);
                    }
                    if (index) {
                        refreshNotSendList();
                    } else {
                        refreshNotSignList();
                    }
                },
                complete: completeSend()
            };
            $.ajax(config);
        }
    }

    // 刷新待签收列表
    function refreshNotSignList() {
        var navFrame = $('.NAP_iframe[data-id="/system/mMailWF/cmnFile/signNotList"]', parent.document)[0];
        navFrame.contentWindow.$.table.refresh();
    }

    // 刷新待分发到下级列表
    function refreshNotSendList() {
        var navFrame = $('.NAP_iframe[data-id="/system/mMailWF/rCity/sendWaitList"]', parent.parent.document)[0];
        navFrame.contentWindow.$.table.refresh();
    }

    // 刷新派单情况列表
    function refreshDealList(iframeName) {
        var navFrame = $(top.window[iframeName])[0];
        navFrame.document.getElementById('navFrame').contentWindow.$.table.refresh();
    }

    function updateState() {
        var data = $('#form-user-add').serializeArray();
        data.push({name: "wfId", value: wfId});
        data.push({name: "pkId", value: sbId});
        var config = {
            url: prefix + '/rManage/sendSon',
            type: "post",
            dataType: "json",
            data: data,
            async: false
        }
        $.ajax(config);
    }

    function SelectDept() {
        var config = {
            id: 'selectDeptDialog',
            title: '选择承办部门<span style="color:red;margin-left: 30px;">双击选中部门</span>',
            width: '1050',
            height: '550',
            url: prefix + '/cmnFile/deptAllM',
            skin: 'layui-layer-gray',
            btn: ['关闭'],
            yes: function (index, layero) {
                top.layer.close(index);
            }
        };
        $.modal.openOptions(config);
    }

    function SonBackSingle(idS, nameS, zpFlagS) {
        $('#deptShort').val(nameS);
        $('#noUnit').val(idS);
        if (zpFlagS !== undefined) $('#zpFlag').val(zpFlagS);
        let sendDesc = $('#sendDesc').val();
        let endIndex = sendDesc.indexOf(" 调");
        let substring = sendDesc.substring(2, endIndex);
        $('#sendDesc').val(sendDesc.replace(substring, nameS));
    }

    function SonDirectSingle(sdeptNo, sdeptName, dNo, dName) {
        $('#deptShort').val(dName);
        $('#noUnit').val(dNo);
        $('#sdeptName').val(sdeptName);
        $('#sdeptId').val(sdeptNo);
    }

    //选择抄送部门
    function selectCopyDeptAll() {
      var config = {
        id: 'selectCopyDeptDialog',
        title: '选择抄送部门<span style="color:red;margin-left: 30px;">双击选中部门</span>',
        width: '1050',
        height: '550',
        url: prefix + '/cmnFile/copyDeptAll',
        skin: 'layui-layer-gray',
        btn: ['关闭'],
        yes: function (index, layero) {
          top.layer.close(index);
        }
      };
      $.modal.openOptions(config);
    }

    function copyToSonBackSingle(idS, nameS) {
      $('#copyToDeptName').val(nameS);
      $('#copyToDeptId').val(idS);
    }

    function copyToDept(){
      let deptNames = $('#copyToDeptName').val();
      let deptNos = $('#copyToDeptId').val();
      let data = {
        "wfId":wfId,
        "deptNos": deptNos,
        "deptNames" : deptNames
      }
      $.ajax({
        url: ctx + 'system/mMailWF/copy',
        type: "post",
        dataType: "json",
        data: data
      });
    }

    //导入备注
    function getContent() {
        var sendRemark = $("#sendRemark").val();
        $("#remark").val(sendRemark);
    }

    //是否开启短信通知
    $('[name="smsInform"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
            if (state === true) {
                $(this).val(1);
            } else {
                $(this).val(0);
            }
        }
    });

    $(document).ready(function () {
        //郫都区 开启智能匹配部门
        if ($("#sdeptId").val() == '304240') {
            paidan();
        }
    });

    function chance(i) {
        var id1 = 'e';
        var id2 = 'o';
        id1 = id1 + i;
        id2 = id2 + i;
        var value1 = document.getElementById(id1).value;
        var value2 = $("#" + id2).val();
        var deptShort = $("#deptShort").val();
        var noUnit = $("#noUnit").val();
        var element = document.getElementById(id1);
        if (element.checked) {
            var splitDept;
            if (deptShort.length > 0) {
                splitDept = deptShort.split(',');
                var number = splitDept.indexOf(value1);
                if (number == -1) {
                    deptShort = deptShort + ',' + value1;
                    noUnit = noUnit + ',' + value2;
                }
            } else {
                deptShort = value1;
                noUnit = value2;
            }
            $("#deptShort").val(deptShort);
            $("#noUnit").val(noUnit);
        } else {
            var replace1 = '';
            var replace2 = '';
            var splitDept = deptShort.split(',');
            var splitNo = noUnit.split(',');
            var number = splitDept.indexOf(value1);
            var length = splitDept.length;
            if (number != -1) {
                var splice1 = splitDept.splice(number, 1);
                var splice2 = splitNo.splice(number, 1);
                var len = length - 1;
                for (var i = 0; i < len; i++) {
                    if (len - 1 == i) {
                        replace1 = replace1 + splitDept[i];
                        replace2 = replace2 + splitNo[i];
                    } else {
                        replace1 = replace1 + splitDept[i] + ",";
                        replace2 = replace2 + splitNo[i] + ",";
                    }

                }
            } else {
                replace1 = deptShort;
                replace2 = deptNo;
            }
            $("#deptShort").val(replace1);
            $("#noUnit").val(replace2);
        }


    }

    //智能匹配部门
    function paidan() {
        let url = "/api/bd/assigndept";
        let fmContent = $("input[name='fmContent']").val();
        let dcntAname = $("input[name='dcntAName']").val();
        var data = {
            'content': fmContent,
            'sort': dcntAname
        };
        $.post(url, data, function (result) {
            if (result.length > 0) {
                for (var i = 0; i < result.length; i++) {
                    $("#paidan").append(
                        "<input type=\"checkbox\" value=" + result[i].deptName + " name=" + "e" + i + " id=" + "e" + i + " onclick='chance(" + i + ")'>" + result[i].deptName + " " +
                        "<input type=\"hidden\" value=" + result[i].deptNo + " name=" + "o" + i + " id=" + "o" + i + " onclick='chance(" + i + ")'>"
                    );
                }
                $("#paidan").css('display', '');
            }
        });
    }


    //查看工单详情
    function lookWorkNo() {
        var workNo = $('[name="workNo"]').val();
        var pkId = [[${wfId}]];
        if (workNo == $('[name="workFormNo"]').val()) {
            parent.layer.open({
                type: 2,
                area: ['95%', '95%'],
                title: '信件工单详情',
                content: '/system/lookup/mailOrderDetail/' + pkId,
                shadeClose: true
            });
        } else {
            let url = '/system/lookup/getPKIdByWorkNo/' + workNo;
            $.post(url, function (result) {
                if (result.pkId != null || result.pkId != undefined) {
                    var pkId = result.pkId;
                    parent.layer.open({
                        type: 2,
                        area: ['95%', '95%'],
                        title: '信件工单详情',
                        content: '/system/lookup/mailOrderDetail/' + pkId,
                        shadeClose: true
                    });
                } else {
                    $.modal.alert("查询失败");
                }

            });
        }
    }


    // 添加工单标签
    function makeTag() {
        var mailId = $("[name='originFK']").val();
        var url = ctx + "system/tag/addMailWFTag?mailId=" + mailId;
        var title = "添加工单标签";
        $.modal.open(title, url, '800', '500', callback);
    }

    // 刷新当前页面
    function callback(index, layero) {
        var iframeWin = layero.find('iframe')[0];
        iframeWin.contentWindow.submitHandler();
    }

</script>
</body>
</html>

